package com.yeyks.service.impl;

import com.yeyks.dal.dao.ConfigMapper;
import com.yeyks.dal.domain.Config;
import com.yeyks.exception.ServiceException;
import com.yeyks.service.ConfigService;
import com.yeyks.dal.dao.ConfigMapper;
import com.yeyks.dal.domain.Config;
import com.yeyks.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author fuchangshuai
 * @date 2019/3/11 10:29 AM
 */
@Slf4j
@Service
public class ConfigServiceImpl implements ConfigService {
    @Autowired
    private ConfigMapper configMapper;

    @Override
    public String getValue(String key) {
        Config config = configMapper.selectValueByKey(key);
        if (config == null) {
            log.info("通过key获取不到配置项信息key = {}", key);
            throw new ServiceException("该配置项不存在");
        }
        return config.getValue();
    }
}
